package com.bcntouch.touch2act.Opine;

import android.content.Context;

import com.bcntouch.touch2act.R;

public class Opinions {

	public final static String CURSOS_BACTIVA 	= "1";
	public final static String CARRILS_BICI 	= "2";
	public final static String CIUTAT_BRUTA 	= "3";
	public final static String VIURE_BARCELONA	= "4";
	public final static String ZONES_WIFI 		= "5";
	public final static String FESTES_MERCE 	= "6";
	
	private static Opinion[] opinionsArray = null;
	
	public static Opinion[] getOpinionsArray(Context context) {
		if (opinionsArray == null) {
			Opinion[] tmp = {
					new Opinion(CURSOS_BACTIVA, context.getString(R.string.o_q_cursos_bactiva), context.getString(R.string.educacio), 4896, 3745, 1151, 0/*haveVoted*/, 0/*yourVote*/, 0/*isYours*/),
					new Opinion(CARRILS_BICI, context.getString(R.string.o_q_carrils_bici), context.getString(R.string.mobilitat), 1587, 862, 725, 1/*haveVoted*/, 1/*yourVote*/, 0/*isYours*/),
					new Opinion(CIUTAT_BRUTA, context.getString(R.string.o_q_ciutat_bruta), context.getString(R.string.qualitat_ambiental), 2471, 2156, 315, 0/*haveVoted*/, 0/*yourVote*/, 0/*isYours*/),
					new Opinion(VIURE_BARCELONA, context.getString(R.string.o_q_viure_barcelona), context.getString(R.string.turisme), 541, 332, 209, 0/*haveVoted*/, 0/*yourVote*/, 0/*isYours*/),
					new Opinion(ZONES_WIFI, context.getString(R.string.o_q_zones_wifi), context.getString(R.string.dinamitzacio_economica), 991, 541, 450, 1/*haveVoted*/, 1/*yourVote*/, 1/*isYours*/),
					new Opinion(FESTES_MERCE, context.getString(R.string.o_q_festes_merce), context.getString(R.string.cultura), 3652, 3567, 85, 0/*haveVoted*/, 0/*yourVote*/, 0/*isYours*/)
					};
			
			opinionsArray = tmp;
		}
		
		return opinionsArray;
	}
	
	public static Opinion getOpinionById(Context context, String id) {
		if (id == null)
			return null;
		
		Opinion ret = null;
		Opinion[] opinionsArray = getOpinionsArray(context);
		
		for (Opinion opinion : opinionsArray) {
			if (id.equals(opinion.getId()))
				ret = opinion;
		}
		
		return ret;
	}
	
	public static String[] getQuestions(Context context) {
		Opinion[] opinions = getOpinionsArray(context);
		String[] questions = new String[opinions.length];
		
		for (int i=0; i<opinions.length; i++) {
			questions[i] = opinions[i].getQuestion();
		}
		
		return questions;
	}
}
